#ifndef __CONTROL_H
#define __CONTROL_H

#include "inttypes.h"
#include "pid.h"
typedef enum HostCmdEnum
{
    CMD_SPEED_TARGET_Whole = 1,
    CMD_SPEED_TARGET_LEFT,
    CMD_SPEED_TARGET_RIGHT,
    CMD_SPEED_PID_KP,
    CMD_SPEED_PID_KI,
    CMD_SPEED_PID_KD,

    CMD_PWM_L,
    CMD_PWM_R,

    CMD_STAND_PID_KP,
    CMD_STAND_PID_KI,
    CMD_STAND_PID_KD,

    CMD_RUN,
    CMD_STOP,

    CMD_SET_ANGLE,
    CMD_MUT06,
    CMD_SET_TURN,

    CMD_TURN_PIK_KP,
    CMD_TURN_PIK_KI,
    CMD_TURN_PIK_KD,

} Host_CmdEnumDef;


typedef union FLOAT_CONV {
    float f;
    char  c[4];
} float_conv;

typedef struct Host_CmdStruct {
    uint8_t cmd;
    float   data;
} __attribute__((packed)) Host_CmdStructDef;

#define SAMPLE_TIME_MS 40

#define PWM_MAX 3500
#define PWM_MIN -3500

#define ANGLE_MAX 60
#define ANGLE_MIN -60

extern uint8_t run_flag;

extern float target_angle;
extern float target_turn;

extern float motor_curPwmL;
extern float motor_curPwmR;

extern float pid_speedKp;
extern float pid_speedKi;
// extern float pid_speedKd;

extern float pid_standKp;
// extern float pid_standKi;
extern float pid_standKd;

extern float pid_turnKp;
// extern float pid_turnKi;
extern float pid_turnKd;


extern float pitch, roll, yaw;
extern short gyrox, gyroy, gyroz;
// extern short aacx, aacy, aacz;

// extern Pid_StructDef pidInfo_SpeedL;
// extern Pid_StructDef pidInfo_SpeedR;

extern PidSpeedInfo_StructDef pidInfo_Speed;

void host_cmdDeal(Host_CmdStructDef cmd);

#endif
